using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;

namespace Astro.Core
{
	/// <summary>
	/// Defines a single custom form. This object is stored in the ObjectStore
	/// </summary>
	[Serializable]
    public class CustomCommentFormSettings : CustomFormSettings
	{
		public static readonly string DefaultCustomFormName = "Default::Custom::Comment::Form";
        public static readonly string CustomFormName = "CustomCommentFormSettings-";

		public Guid CommentTypeId;

		/// <summary>
		/// Returns a named custom form. The default post form is named "post".
		/// </summary>
        public static CustomCommentFormSettings Get(string commentTypeId)
        {
            CustomCommentFormSettings cfs = ObjectManager.Get<CustomCommentFormSettings>(CustomFormName + commentTypeId);
            return cfs;
		}

		public void Save()
		{
			if (string.IsNullOrEmpty(Name))
				throw new Exception("The name of the custom form cannot be null");

			this.IsNew = false;
            if (CommentTypeId.Equals(Guid.Empty))
				ObjectManager.Save(this, DefaultCustomFormName);
			else
                ObjectManager.Save(this, CustomFormName + CommentTypeId.ToString());
		}
	}
}
